package cn.lanqiao.demo.service.impl;

import cn.lanqiao.demo.dao.LeaveDao;
import cn.lanqiao.demo.entity.Leave;
import cn.lanqiao.demo.service.LeaveService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*学生请假Service实现类*/
@Service
public class LeaveServiceImpl implements LeaveService {
    @Resource
    LeaveDao leaveDao;

    /*学生添加请假条*/
    @Override
    public int addLeave(String Sname, String reason, String time, String place, String status, String Sno) throws Exception {
        return leaveDao.addLeave(Sname,reason,time,place,status,Sno);
    }

    /*根据学号展示请假条*/
    @Override
    public List<Leave> showLeaveBySno(String Sno) throws Exception {
        return leaveDao.showLeaveBySno(Sno);
    }


    /*学生修改请假条*/
    @Override
    public int updateLeaveBySno(String reason, String time, String place, String Sno) throws Exception {
        return leaveDao.updateLeaveBySno(reason,time,place,Sno);
    }

    /*学生给根据请假条编号，删除请假条*/
    @Override
    public int delete(int Lno) throws Exception {
        return leaveDao.delete(Lno);
    }

    /*显示所有学生假条*/
    @Override
    public List<Leave> showAll() throws Exception {
        return leaveDao.showAll();
    }

    /*查询所有 未批阅 的学生假条，status=0的*/
    @Override
    public List<Leave> notCheck() throws Exception {
        return leaveDao.notCheck();
    }

    /*老师不同意学生请假，status从0变成1*/
    @Override
    public int unallowLeave(int Lno) throws Exception {
        return leaveDao.unallowLeave(Lno);
    }

    /*老师同意学生请假，status从1变成2*/
    @Override
    public int allowLeave(int Lno) throws Exception {
        return leaveDao.allowLeave(Lno);
    }

}
